package com.hx.company.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hx.company.MerchantInterface;
import com.hx.company.dao.MerDao;
import com.hx.company.dao.UserDao;
import com.hx.company.vo.Food;
import com.hx.company.vo.Merchant;
import com.hx.company.vo.Order;
import com.hx.company.vo.UserLogin;

@Service("me")
public class MerchantInterfaceImple implements MerchantInterface {
	@Autowired(required=true)
	private MerDao mrd;
	

	@Override
	@Transactional
	public Boolean MerchantLogin(com.hx.company.vo.MerchantLogin m) {
		Boolean i=false;
		List<com.hx.company.vo.MerchantLogin> cs= mrd.find(m);
		System.out.println(cs.size()+"--");
		if(cs.size()!=0){
			for(com.hx.company.vo.MerchantLogin u:cs){
				if(m.getMpassword().equals(u.getMpassword())){
					i=true;
				}
				
			}
		}
		
		
		
		return i;
	}

	@Override
	@Transactional
	public List<Food> getMerchantFood(String mid) {
		
		return mrd.getFood(mid);
	}

	@Override
	public List<Order> getOrder(String mphone) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void sendOrder(String message) {
		// TODO Auto-generated method stub
		
	}

	@Override
	@Transactional
	public Boolean MerchantRegister(Merchant mc, com.hx.company.vo.MerchantLogin ml) {
		
		return mrd.addMer(mc,ml);
	}

	@Override
	@Transactional
	public String getPicName() {
		
		
		return mrd.getPicName();
		
		
	}

	@Override
	@Transactional
	public String getMid(String phone) {
		
		
		return mrd.getMid(phone);
	}
	
	
	

}
